/*
 * Copyright 2016 Wealth Inc. All rights reserved.
 */
package com.wealth.bbs.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.wealth.member.entity.Member;

@Entity
@Table(name = "bbs_reply")
public class Reply implements Comparable<Reply>,Serializable {

	private static final long serialVersionUID = 1L;

	private Long id;
	private String content;
	private Integer status;
	private String creator;
	private Date createTime;
	
	private Topic topic;
	private Member member; 

	
	/* ---------------- method ---------------- */
	
	public Reply() {
	}

	public Reply(Long id) {
		this.id=id;
	}

	/* ---------------- getter/setter ----------------*/
	
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(name = "content")
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
	
	@Column(name = "status")
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
	
	@Column(name = "creator")
	public String getCreator() {
		return creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}
	
	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	@ManyToOne
	@JoinColumn(name = "topic_id")
	public Topic getTopic() {
		return topic;
	}

	public void setTopic(Topic topic) {
		this.topic = topic;
	}

	@ManyToOne
	@JoinColumn(name = "member_id")
	public Member getMember() {
		return member;
	}

	public void setMember(Member member) {
		this.member = member;
	}
	
	@Override
	//1->10
	public int compareTo(Reply o) {
		// TODO Auto-generated method stub
		if (this.id < o.getId()) {
			return -1;
		}
		else if (this.id > o.getId()) {
			return 1;
		}
		else{
			return 0;	
		}
	}

}
